package il.ac.tau.dbcourse.gui;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;

public class Mp3Player implements Runnable {
	Player player;
				
	public Mp3Player(Player player) {
		super();
		this.player = player;
	}

	@Override
	public void run() {		
		try {
			player.play();
		} catch (JavaLayerException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) throws FileNotFoundException, Exception {
		Player player = new Player(new FileInputStream("c:\\1" +".mp3"));
		
		Thread playerThread = new Thread(new Mp3Player(player));
		playerThread.start();				
		
		for (int i = 15; i > 0; i--) {
			System.out.println("Killing in " + i + " ...");
			Thread.sleep(1000);					
		}
		
		player.close();

	}	
}
